package com.googlecode.garbagecan.jmsstudy.activemq.spring1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;

public class Client {

	public static void main(String[] args) throws IOException {
		ApplicationContext context = new ClassPathXmlApplicationContext("/com/googlecode/garbagecan/jmsstudy/activemq/spring1/client-context.xml");
		JmsTemplate jmsTemplate = (JmsTemplate) context.getBean("jmsTemplate");
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			System.out.print("To Register, Enter Name: ");
			String name = reader.readLine();
			if (name == null || name.trim().length() == 0) {
				continue;
			}
			RegistrationRequest request = new RegistrationRequest(name);
			jmsTemplate.convertAndSend(request);
		}
	}
}
